package com.yibo.support.inter;

import com.yibo.support.context.SpringContext;
import com.yibo.support.exception.YBException;

/**
 * 命令
 */
public interface Command<T>  {

    /**
     * 命令执行
     * @return  返回值
     */
    T   execute();


    /**
     * 获取bean
     * @param clazz  类型
     * @param <B>    B
     * @return     类
     */
    default  <B>B  getBean(Class<B> clazz){
        B b =  SpringContext.getBean(clazz);
        if(b == null){
            throw new YBException("未注册上下文！");
        }
        return b;
    }
}
